package com.gudy.counter.service.impl;

import com.gudy.counter.bean.CounterRes;
import com.gudy.counter.bean.OrderInfo;
import com.gudy.counter.service.EntrustService;
import com.gudy.counter.util.ConstCommon;
import com.gudy.counter.util.DBUtil;
import com.gudy.counter.util.TimeformatUtil;
import io.micrometer.core.instrument.util.StringUtils;
import org.springframework.stereotype.Service;
import org.sqlite.date.DateFormatUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;

@Service
public class EntrustServiceImpl implements EntrustService {
    @Override
    public CounterRes queryDayEntrust(HttpServletRequest request) {
        String uid = request.getParameter("uid");
        String sign = request.getParameter("sign");
        Date currentDate = new Date();
        String date = TimeformatUtil.yyyyMMdd(currentDate);
        List<OrderInfo> orderInfos = null;
        if (StringUtils.isEmpty(sign)){
            orderInfos = DBUtil.queryOrderAndsaleOrder(date,Long.valueOf(uid),request.getParameter("code"),request.getParameter("startDate"),request.getParameter("endDate"),request.getParameter("status"));
        }else if (sign.equals("1")){
            orderInfos = DBUtil.queryOrderAndsaleOrder("",Long.valueOf(uid),request.getParameter("code"),request.getParameter("startDate"),request.getParameter("endDate"),request.getParameter("status"));
        }


        return new CounterRes(ConstCommon.SUCCESS,"获取当日委托成功",orderInfos);
    }
}
